﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace z6
{
    class Program
    {
        static void Main(string[] args)
        {
            //((((1 ? 2) ? 3) ? 4) ? 5) ? 6

            double n = 5;//количество заков
            double x = 4;//степень
            int count1 = 0, count2 = 0, count3 = 0, count4 = 0, count5 = 0;
            File.WriteAllText(".\\..\\..\\write.txt","");
            for (int i = 0; i < Math.Pow(x, n); i++)
            {
                char z1 = ' ', z2 = ' ', z3 = ' ', z4 = ' ', z5 = ' ';
                if (count1 == 4)
                {
                    count1 = 0;
                    count2++;
                }
                else if (count2 == 4)
                {
                    count2 = 0;
                    count3++;
                }
                else if (count3 == 4)
                {
                    count3 = 0;
                    count4++;
                }
                else if (count4 == 4)
                {
                    count4 = 0;
                    count5++;
                }
                //Первый символ
                z1 = funk(count1);
                //Второй символ
                z2 = funk(count2);
                //третий символ
                z3 = funk(count3);
                //Четвертый символ
                z4 = funk(count4);
                //Пятый символ
                z5 = funk(count5);
                string str = "((((1 " + z5 + " 2) " + z4 + " 3) " + z3 + " 4) " + z2 + " 2) " + z1 + " 6" + "\n";
                File.AppendAllText(".\\..\\..\\write.txt", str);
                Console.WriteLine("((((1 " + z5 + " 2) " + z4 + " 3) " + z3 + " 4) " + z2 + " 2) " + z1 + " 6");
                count1++;
            }
        }
        public static char funk(int count)
        {
            if (count == 0)
            {
                return '+';
            }
            else if (count == 1)
            {
                return '-';
            }
            else if (count == 2)
            {
                return '*';
            }
            else
            {
                return '/';
            }
        }
    }
}
